package com.sjk.flink.schema;

import com.fasterxml.jackson.databind.JsonNode;
import networknt.schema.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RelevanceKeyWord extends AbstractKeyword {
    private  final Logger logger = LoggerFactory.getLogger(RelevanceKeyWord.class);

    public RelevanceKeyWord() {
        super("relevance");
    }

    @Override
    public JsonValidator newValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) throws
            JsonSchemaException, Exception {
        System.out.println("CompareField_schemaPath:"+schemaPath+",schemaNodeValue:"+schemaNode+" parentSchemaNodeKv:"+ parentSchema+",validationContext="+validationContext);

        //String config = schemaNode.asText();
        /**
         AbstractJsonValidator abstractJsonValidator = new AbstractJsonValidator() {
        @Override
        public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
        System.out.println("CompareField.validate_config:"+config+",path:"+at+",node:"+ node);
        System.out.println("CompareField.validate_rootNode="+rootNode);
        return Collections.emptySet();
        }
        };
         return abstractJsonValidator;
         **/
        //System.out.println(">>>>>>>>>>>>>>>>>       "+config);
        //ValidatorTypeCode typeCode = ValidatorTypeCode.REQUIRED;
        // Set custom error message
        //typeCode.setCustomMessage(this.type.getCustomMessage());
        return new TimelinessValidator(schemaPath,schemaNode,parentSchema,validationContext, ValidatorTypeCode.TIMELINESS);
    }
}